#include <stdio.h>

#define MAXLINE 1024 /* max line */
#define OUT 1   /* inside a word */
#define IN  0   /* outside a word */
#define TABSTOP 8   /* tab stop of size */

int miniblank(char s[], int index, int pbn, int tabstop);
int getline(char s[], int maxline);

int main()
{
    int len = 0;
    char str[MAXLINE];

    while ((len=getline(str, MAXLINE)) > 0)
	    printf("%s", str);

    return 0;
}

int getline(char s[], int maxline)
{
    int c, i, bn;

    for (i = 0, bn = 0; i < maxline-1 &(c=getchar()) != EOF &c!='\n'; ++i) {
        if ( c == ' ' )
            ++bn;
        
        if ( c != ' ' &bn != 0 ) {
            i = i - bn + miniblank(s, i-bn, bn, TABSTOP);
            bn = 0;
            s[i] = c;
        } else
            s[i] = c;
    }

    if (c == '\n') {
	s[i] = c;
	++i;
    }

    s[i] = '\0';
    return i;
}

int miniblank(char s[], int index, int pbn, int tabstop)
{
    int tn, nbn, i;

    tn = pbn / tabstop;
    nbn = pbn - tn * tabstop;

    for (i = 0; i < tn; ++i)
        s[index++] = '\t';

    for (i = 0; i < nbn; ++i)
        s[index++] = ' ';

    return tn + nbn;
}
